package kayao.client.input;

import kayao.client.data.SharedMemory;
import android.view.MotionEvent;
import android.view.View;
import android.view.GestureDetector.OnGestureListener;
import android.view.View.OnTouchListener;

/**
* Handles all input from the phone touchscreen.
*/
public class TouchscreenInput implements OnTouchListener, OnGestureListener {

	@Override
	public boolean onTouch(View view, MotionEvent e) {
		sleep();
		return false;
	}

	@Override
	public boolean onDown(MotionEvent e) {
		if(e.getX()<(SharedMemory.getInstance().getScreenWidth()/2))
			SharedMemory.getInstance().setOutgoingMessage("screwed");
		else
			SharedMemory.getInstance().setOutgoingMessage("werock");
		return false;
	}

	@Override
	public boolean onFling(MotionEvent e, MotionEvent arg1, float arg2, float arg3) {
		return false;
	}

	@Override
	public void onLongPress(MotionEvent e) {
	}

	@Override
	public boolean onScroll(MotionEvent e, MotionEvent arg1, float arg2, float arg3) {
		return false;
	}

	@Override
	public void onShowPress(MotionEvent e) {
	}

	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		return false;
	}
	
	private void sleep() {
		try {
			Thread.sleep(30);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
